package com.gxar.quick.ar.server.base.common.enums.protocol;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * AR作品制作方法
 *
 * @author zxh
 * @version 1.0
 * @created 2024/01/02.
 */
@Getter
public enum ArProductMethodEnum {

    EASY_MAKE(0, "easy", "简易制作"),
    ADVANCED(1, "advanced", "进阶制作"),
    UNITY(2, "unity", "unity制作"),

    ;

    private final Integer code;
    private final String name;
    private final String desc;

    ArProductMethodEnum(Integer code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    @JsonCreator
    public static ArProductMethodEnum getByCode(Integer code) {
        Optional<ArProductMethodEnum> targetEnum = Arrays.stream(ArProductMethodEnum.values()).filter(e -> e.getCode().equals(code)).findFirst();
        return targetEnum.orElse(null);
    }

    @JsonCreator
    public static ArProductMethodEnum getByName(String name) {
        Optional<ArProductMethodEnum> targetEnum = Arrays.stream(ArProductMethodEnum.values()).filter(e -> e.getName().equals(name)).findFirst();
        return targetEnum.orElse(null);
    }
}
